var vm = new Vue({
    el:"#app",
    data(){
        return {
            //搜索条件
            Theme:'',
            ThemeList:[],
            FirstLevelShouRuList:[],
            ShouRuTotalMoney:'',
            FirstLevelZhiChuList:[],
            ZhiChuTotalMoney:'',
            modal1: false,   //明细弹框
            columns1: [
                {
                    type: 'index',
                    title: '序号',
                    width:46,
                    align: 'center',
                },
                {
                    title: '项目名称',
                    key: 'ProjectName',
                    align: 'center',
                    width:300,
                },
                {
                    title: '东二环店',
                    key: 'DEH',
                    align: 'center',
                },
                {
                    title: '建华店',
                    key: 'JH',
                    align: 'center',
                },
                {
                    title: '金利来店',
                    key: 'JLL',
                    align: 'center',
                },
                {
                    title: '北杜店',
                    key: 'BD',
                    align: 'center',
                },
                {
                    title: '西二环店',
                    key: 'XEH',
                    align: 'center',
                },
                {
                    title: '北二环店',
                    key: 'BEH',
                    align: 'center',
                },
                {
                    title: '霸州店',
                    key: 'BZ',
                    align: 'center',
                },
                {
                    title: '邢台店',
                    key: 'XT',
                    align: 'center',
                }
            ],
            data1: []

        }
    },
    created(){
        this.initThisPage();
        this.queryTheme();
    },
    methods:{
        ok () {
        },
        cancel () {
        },
        // 编辑弹框
        edit(){
            this.modal1=true;
        },
        queryTheme(){
            var self = this;
            $.ajax({
                url: "./goProject/queryTheme", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                dataType: "json", //返回格式为json
                type: "GET", //请求方式
                headers : {
                    'Content-Type' : 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    var ThemeList = data.ThemeList;
                    for(var i=0;i<ThemeList.length;i++){
                        var temp = {
                            value: ThemeList[i].ThemeName,
                            label: ThemeList[i].ThemeName
                        };
                        self.ThemeList.push(temp)
                    }
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function(data) {

                }
            });
        },
        initThisPage(){
            var self = this;
            $.ajax({
                url: "./goLogin/initIndexPage", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                async:false,
                dataType: "json", //返回格式为json
                type: "GET", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    if(data.Status==0){
                        // top.location.href = "../../login.html";
                        window.location.href="../../login.html";
                    }
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function() {}
            });
        },
        queryShouAndZhi(){
            var self = this;
            var Theme = self.Theme;
            if(Theme==""||Theme==null){
                toastr.warning("请选择活动主题");
                return false;
            }
            this.queryShouRuMoneyByType(Theme);
            this.queryZhiChuMoneyByType(Theme);
        },
        queryShouRuMoneyByType(Theme){
            var self = this;
            var info ;

            var jsondata={"Type":"收入","Theme":Theme};
            var data_json = JSON.stringify(jsondata);
            $.ajax({
                url: "./goProject/queryMoneyByType", //请求的url地址
                dataType: "json", //返回格式为json
                data: data_json, //参数值
                async:false,
                type: "POST", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                success: function(data) {
                    self.FirstLevelShouRuList =data.ResultList;
                    self.ShouRuTotalMoney = data.TypeMoney;
                },
                error: function() {},
            });
        },
        queryZhiChuMoneyByType(Theme){
            var self = this;
            var info ;
            var jsondata={"Type":"支出","Theme":Theme};
            var data_json = JSON.stringify(jsondata);
            $.ajax({
                url: "./goProject/queryMoneyByType", //请求的url地址
                dataType: "json", //返回格式为json
                data: data_json, //参数值
                async:false,
                type: "POST", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                success: function(data) {
                    self.FirstLevelZhiChuList =data.ResultList;
                    self.ZhiChuTotalMoney = data.TypeMoney;
                },
                error: function() {},
            });
        },
        queryStoreDataInfo(TopID,TopName){
            var self = this;
            var Theme = self.Theme;
            var info ;
            var jsondata={"TopID":TopID,"TopName":TopName,"Theme":Theme};
            var data_json = JSON.stringify(jsondata);
            $.ajax({
                url: "./goProject/queryStoreDataInfo", //请求的url地址
                dataType: "json", //返回格式为json
                data: data_json, //参数值
                async:false,
                type: "POST", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                success: function(data) {
                    self.data1 = data.ResultList;
                    self.modal1 = true;
                },
                error: function() {},
            });
        },

        //手机号验证
        isPoneAvailable(str) {
            var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
            if (!myreg.test(str)) {
                return false;
            } else {
                return true;
            }
        },
    }
})